<?php
namespace AdminApi\Controller;
use Zend\Mvc\Controller\AbstractRestfulController;
use Zend\View\Model\JsonModel;
class RegistrationApiController extends AbstractRestfulController
{
    public function getList()
    {			
		header('Access-Control-Allow-Origin: *');
		$request = $this->getRequest();
		$headers = $request->getHeaders();
		echo "<pre>";print_r($headers);exit;
		$data=array();		
		$userTable=$this->getServiceLocator()->get('Models\Model\UserFactory');
		$userData = $userTable->getUserData($user_id)->toArray();
		if(count($userData)!=0){
			return new JsonModel(array(
				'data' => json_encode($data),
			));
		}else{
			return new JsonModel(array(
				'output' => 'no data',
			));
		}
    }
    public function get($user_id)
    {		
		header('Access-Control-Allow-Origin: *');
		$data=array();		
		$userTable=$this->getServiceLocator()->get('Models\Model\UserFactory');
		$userData = $userTable->getUserData($user_id);
		if(count($userData)!=0){
			foreach($userData as $user){
				$data[]=$user;
			}
			return new JsonModel(array(
				'data' => json_encode($data),
			));
		}else{
			return new JsonModel(array(
				'output' => 'no data',
			));
		}
    }
    public function create($data)
    {
		header('Access-Control-Allow-Origin: *');
		
		$userTable=$this->getServiceLocator()->get('Models\Model\UserFactory');
		$shopData = $userTable->getShopsByFilter($data)->toArray();
		if(count($shopData)!=0){
			return new JsonModel(array(
				'data' => json_encode($shopData),
			));
		}else{
			return new JsonModel(array(
				'output' => 'no data',
			));
		}
    }
    public function update($uid, $data)
    {
		header('Access-Control-Allow-Origin: *');	
		$userTable=$this->getServiceLocator()->get('Models\Model\UserFactory');
		$result = $userTable->changeUserStatus($data,$uid);
		if($result!=0){
			return new JsonModel(array(
				'output' => 'success',
			));
		}else{
			return new JsonModel(array(
				'output' => 'not success',
			));
		}
    }
    public function delete($id)
    {
       
    }
}